class Solution {
public:
    int maxDepth(Node* root) {
        if (!root) return 0;
        int size = root->children.size();
        int result = 0;
        for (int i = 0; i < size; ++i) {
            result = max(result, maxDepth(root->children[i]));
        }
        return result + 1;
    }

    int maxDepth_1(Node* root) {
        if (!root) return 0;
        int result = 0;
        queue<Node *> q;
        q.push(root);
        while (!q.empty()) {
            int size = q.size();
            result++;
            for (int i = 0; i < size; ++i) {
                Node *node = q.front();
                q.pop();
                int nSize = node->children.size();
                for (int j = 0; j < nSize; ++j) {
                    if (node->children[j]) q.push(node->children[j]);
                }
            }
        }
        return result;
    }
};